package menu

import (
	"context"
	"git.mycaigou.com/gfyx/common/tenant_db"
	"git.mycaigou.com/gfyx/micro-gfyx-oppty-service/infrastructure/common/constants"
	"gorm.io/gorm"
)

type menuRepository struct {
	tenant_db.TenantDB
}

// NewMenuRepository 构造函数
func NewMenuRepository() MenuRepositoryIface {
	return &menuRepository{}
}

// MenuList 菜单列表
func (r *menuRepository) MenuList(ctx context.Context) ([]*GfyxMenuPo, error) {
	menuList := make([]*GfyxMenuPo, 0)
	err := r.GetTenantDB(ctx).Where("is_deleted = ?", constants.IsDeletedFalse).Find(&menuList).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, err
	}
	return menuList, err
}
